package com.zoffy.oj_backend.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zoffy.oj_backend.common.BaseResponse;
import com.zoffy.oj_backend.common.ResultUtils;
import com.zoffy.oj_backend.model.dto.questionSubmit.QuestionSubmitAddRequest;
import com.zoffy.oj_backend.model.dto.questionSubmit.QuestionSubmitQueryRequest;
import com.zoffy.oj_backend.model.dto.questionSubmit.QuestionSubmitTinyQueryRequest;
import com.zoffy.oj_backend.model.vo.QuestionSubmitTinyVo;
import com.zoffy.oj_backend.model.vo.QuestionSubmitVo;
import com.zoffy.oj_backend.service.QuestionSubmitService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@RestController("/question_submit")
public class QuestionSubmitController {
    @Resource
    QuestionSubmitService questionSubmitService;
    @PostMapping("/list/page/vo")
    public BaseResponse<IPage<QuestionSubmitVo>> listQuestionSubmitVoByPage(@RequestBody QuestionSubmitQueryRequest questionSubmitQueryRequest){
        IPage<QuestionSubmitVo> questionSubmitVoIPage = questionSubmitService.listQuestionSubmitByPage(questionSubmitQueryRequest);
        return ResultUtils.success(questionSubmitVoIPage);
    }
    @PostMapping("/list/page/mine/vo")
    public BaseResponse<IPage<QuestionSubmitTinyVo>> listMyQuestionSubmitTinyVoByPage(@RequestBody QuestionSubmitTinyQueryRequest queryRequest,HttpServletRequest request){
        IPage<QuestionSubmitTinyVo> questionSubmitVoIPage = questionSubmitService.listMyQuestionSubmitTinyVoByPage(request,queryRequest);
        return ResultUtils.success(questionSubmitVoIPage);
    }
    @PostMapping("/add")
    public BaseResponse<Long> addQuestionSubmit(@RequestBody QuestionSubmitAddRequest questionSubmitAddRequest, HttpServletRequest request){
        Long id = questionSubmitService.doQuestionSubmit(questionSubmitAddRequest, request);
        return ResultUtils.success(id);
    }

}
